home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3863 / 3863.xpi / chrome / imacros.jar / content / MacroPlayer.js < prev    next >
Text File  |  2010-01-25  |  62KB  |  5 lines

  1.  
  2. /*
  3. (c) Copyright 2008 iOpus Software GmbH - http://www.iopus.com
  4. */
  5. function BadParameter(msg,num){this.message=typeof(num)!="undefined"?"expected "+msg+" as parameter "+num:msg;this.name="BadParameter";this.errnum=911;};BadParameter.prototype=Error.prototype;function UnsupportedCommand(msg){this.message="command "+msg+" is not supported in the current version";this.name="UnsupportedCommand";this.errnum=912;};UnsupportedCommand.prototype=Error.prototype;function RuntimeError(msg,num){this.message=msg;if(typeof num!="undefined")this.errnum=num;this.name="RuntimeError";};RuntimeError.prototype=Error.prototype;SyntaxError.prototype.__defineGetter__("errnum",function(){return 910;});function ShouldWaitSignal(playAgain,delay){this.playAgain=playAgain;this.delay=delay;};function MacroPlayer(){this.m_wnd=null;this.vars=new Array(3);this.userVars=new Object();this.compileExpressions();};MacroPlayer.prototype.ActionTable=new Object();MacroPlayer.prototype.RegExpTable=new Object();const im_strre="(?:\"(?:[^\"\\\\]|\\\\[0btnvfr\"\'\\\\])*\"|\\S*)";MacroPlayer.prototype.RegExpTable["add"]="^(\\S+)\\s+("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["add"]=function(cmd){var param=unwrapLine(mplayer.expandVariables(cmd[2]));var arr=null,num;if(arr=cmd[1].match(/^!var([123])$/i)){num=__int(arr[1]);var n1=__int(mplayer.vars[num]),n2=__int(param);if(!isNaN(n1)&& !isNaN(n2)){mplayer.vars[num]=(n1+n2).toString();}else{mplayer.vars[num]+=param;}}else if(arr=cmd[1].match(/^!extract$/i)){mplayer.addExtractData(param);}else{throw new BadParameter("!VAR[123] or !EXTRACT",1);}};MacroPlayer.prototype.RegExpTable["back"]="^\\s*$";MacroPlayer.prototype.ActionTable["back"]=function(cmd){getWebNavigation().goBack();};MacroPlayer.prototype.RegExpTable["clear"]="^\\s*$";MacroPlayer.prototype.ActionTable["clear"]=function(cmd){var cachesvc=imns.Cc["@mozilla.org/network/cache-service;1"].getService(imns.Ci.nsICacheService);cachesvc.evictEntries(imns.Ci.nsICache.STORE_ANYWHERE);var cookiemgr=imns.Cc["@mozilla.org/cookiemanager;1"].getService(imns.Ci.nsICookieManager);cookiemgr.removeAll();};MacroPlayer.prototype.RegExpTable["click"]="^x\\s*=\\s*(\\S+)\\s+y\\s*=\\s*(\\S+)"+"(?:\\s+content\\s*=\\s*("+im_strre+"))?\\s*$";var ClickHandler={visibleElement:function(element){return element.offsetWidth&&element.offsetHeight;},withinElement:function(element,x,y){var pos=this.getElementLUCorner(element);return(x>=pos.x&&x<=pos.x+element.offsetWidth&&y>=pos.y&&y<=pos.y+element.offsetHeight);},getInnermostElement:function(element,x,y){var children=element.childNodes,tmp;for(var i=0;i<children.length;i++){if(children[i].nodeType!=Node.ELEMENT_NODE)continue;if(this.visibleElement(children[i])){if(this.withinElement(children[i],x,y)){return this.getInnermostElement(children[i],x,y);}}else{if(children[i].childNodes.length){tmp=this.getInnermostElement(children[i],x,y);if(tmp!=children[i])return tmp;}}}return element;},getElementByXY:function(win,x,y,useOldMethod){var doc=win.document;if("nsIDOMWindowUtils"in imns.Ci&& !useOldMethod){var req=win.top.QueryInterface(imns.Ci.nsIInterfaceRequestor);var utils=req.getInterface(imns.Ci.nsIDOMWindowUtils);var doc_el=doc.documentElement;var body=doc.body;var clientTop=doc_el.clientTop||body.clientTop||0;var clientLeft=doc_el.clientLeft||body.clientLeft||0;var scrollX=win.scrollX||doc_el.scrollLeft||body.scrollLeft;var scrollY=win.scrollY||doc_el.scrollTop||body.scrollTop;var x_rel=x-scrollX+clientLeft,y_rel=y-scrollY+clientTop;return utils.elementFromPoint(x_rel,y_rel,true,false);}var nodes=doc.getElementsByTagName("*");for(var i=0;i<nodes.length;i++){if(this.withinElement(nodes[i],x,y)){var element=this.getInnermostElement(nodes[i],x,y);if(element.tagName!="FRAME"){return element;}else{for(var j=0;j<win.frames.length;j++){if(win.frames[j].frameElement==element){return this.getElementByXY(win.frames[j],x,y);}}}}}return null;},calculateOffset:function(element){var x=0,y=0;while(element){x+=element.offsetLeft;y+=element.offsetTop;element=element.offsetParent;}return{x:x,y:y};},getElementLUCorner:function(element,useOldMethod){if(element.getBoundingClientRect&& !useOldMethod){var rect=element.getBoundingClientRect();var win=element.ownerDocument.defaultView;var doc=win.document;var doc_el=doc.documentElement;var body=doc.body;var clientTop=doc_el.clientTop||body.clientTop||0;var clientLeft=doc_el.clientLeft||body.clientLeft||0;var scrollX=win.scrollX||doc_el.scrollLeft||body.scrollLeft;var scrollY=win.scrollY||doc_el.scrollTop||body.scrollTop;var x=rect.left+scrollX-clientLeft;var y=rect.top+scrollY-clientTop;return{x:Math.round(x),y:Math.round(y)};}else{var e=element;var pos={x:0,y:0};while(e){var tpos=this.calculateOffset(e);pos.x+=tpos.x;pos.y+=tpos.y;e=e.ownerDocument.defaultView.frameElement;}return pos;}},findElementPosition:function(element,useOldMethod){var width,height;if(element.getBoundingClientRect&& !useOldMethod){var rect=element.getBoundingClientRect();width=rect.right-rect.left;height=rect.bottom-rect.top;}else{width=element.offsetWidth;height=element.offsetHeight;}var pos=this.getElementLUCorner(element,useOldMethod);pos.x+=Math.round(width/2);pos.y+=Math.round(height/2);return pos;}};MacroPlayer.prototype.ActionTable["click"]=function(cmd){var x=__int(unwrapLine(mplayer.expandVariables(cmd[1])));var y=__int(unwrapLine(mplayer.expandVariables(cmd[2])));var content="";if(isNaN(x))throw new BadParameter("integer",2);if(isNaN(y))throw new BadParameter("integer",3);if(cmd[3]){content=unwrapLine(mplayer.expandVariables(cmd[3]));}var element=ClickHandler.getElementByXY(mplayer.currentWindow,x,y);if(!element)throw new RuntimeError("can not find element specified by"+" ("+x+", "+y+")",920);if(im_Pref.getBoolPref("highlight")){element.style.borderColor="#0000ff";element.style.borderWidth="2px";element.style.borderStyle="solid";}if(im_Pref.getBoolPref("scroll")){mplayer.currentWindow.scrollTo(x-100,y-100);}TagHandler.simulateClick(element);if(content)TagHandler.onContentParam(element.tagName.toLowerCase(),element,content);};MacroPlayer.prototype.RegExpTable["cmdline"]="^(\\S+)\\s+("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["cmdline"]=function(cmd){var param=unwrapLine(mplayer.expandVariables(cmd[2]));var found=false;if(/^!(\S+)$/i.test(cmd[1])){var val=RegExp.$1.toLowerCase();if(val=="timeout"){if(isNaN(__int(param)))throw new BadParameter("integer",2);mplayer.timeout=__int(param);}else if(val=="loop"){if(isNaN(__int(param)))throw new BadParameter("integer",2);mplayer.currentLoop=__int(param);}else if(val=="datasource"){mplayer.loadDataSource(param);}else if(/^var([123])/.test(val)){mplayer.vars[__int(RegExp.$1)]=param;}else{throw new BadParameter("!TIMEOUT|!LOOP|!DATASOURCE|!VAR[123]",1);}}else{if(mplayer.hasUserVar(cmd[1])){mplayer.setUserVar(cmd[1],param);}else{throw new BadParameter("unknown variable "+cmd[1]);}}};MacroPlayer.prototype.RegExpTable["disconnect"]=".*";MacroPlayer.prototype.ActionTable["disconnect"]=function(cmd){throw new UnsupportedCommand("DISCONNECT");};MacroPlayer.prototype.RegExpTable["ds"]=".*";MacroPlayer.prototype.ActionTable["ds"]=function(cmd){throw new UnsupportedCommand("DS");};MacroPlayer.prototype.RegExpTable["extract"]=".*";MacroPlayer.prototype.ActionTable["extract"]=function(cmd){throw new UnsupportedCommand("EXTRACT");};MacroPlayer.prototype.RegExpTable["filedelete"]="^name\\s*=\\s*("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["filedelete"]=function(cmd){var param=unwrapLine(mplayer.expandVariables(cmd[1])),file;if(param.indexOf(__psep())== -1){var file=im_Pref.getFilePref("defdownpath");file.append(param);}else file=im_FIO.openNode(param);file.remove(false);};MacroPlayer.prototype.RegExpTable["filter"]="^type\\s*=\\s*(\\S+)\\s+"+"status\\s*=\\s*(\\S+)\\s*$";MacroPlayer.prototype.ActionTable["filter"]=function(cmd){var param=unwrapLine(mplayer.expandVariables(cmd[2]));if(mplayer.shouldFilterImages){var watcher=getRequestWatcher();if(!/^images$/i.test(cmd[1])){throw new BadParameter("TYPE=IMAGES",1);}if(/^on$/i.test(param))watcher.enableImageFilter();else watcher.enableImageFilter(false);}};MacroPlayer.prototype.RegExpTable["frame"]="^(f|name)\\s*=\\s*("+im_strre+")\\s*$";MacroPlayer.prototype.findFrame=function(win,obj){var frames=win.frames,i,f;for(i=0;i<frames.length;i++){if(--obj.num==0){return frames[i];}else if(f=this.findFrame(frames[i],obj))return f;}return null;};MacroPlayer.prototype.findFrameByName=function(win,name){var frames=win.frames,i;for(var i=0;i<frames.length;i++){if(frames[i].name==name)return frames[i];else if(f=this.findFrameByName(frames[i],name))return f;}return null;};MacroPlayer.prototype.ActionTable["frame"]=function(cmd){var type=cmd[1].toLowerCase(),f=null;var param=unwrapLine(mplayer.expandVariables(cmd[2]));if(type=="f"){param=__int(param);if(isNaN(param))throw new BadParameter("F=<number>",1);if(param==0){mplayer.currentWindow=window.content;}else if(f=mplayer.findFrame(window.content,{num:param})){mplayer.currentWindow=f;}else{mplayer.currentWindow=window.content;throw new RuntimeError("frame "+param+" not found",921);}}else if(type=="name"){if(!(f=mplayer.findFrameByName(window.content,param))){mplayer.currentWindow=window.content;throw new RuntimeError("frame "+param+" not found",921);}else{mplayer.currentWindow=f;}}};MacroPlayer.prototype.RegExpTable["imageclick"]=".*";MacroPlayer.prototype.ActionTable["imageclick"]=function(cmd){throw new UnsupportedCommand("IMAGECLICK");};MacroPlayer.prototype.RegExpTable["imagesearch"]=".*";MacroPlayer.prototype.ActionTable["imagesearch"]=function(cmd){throw new UnsupportedCommand("IMAGESEARCH");};MacroPlayer.prototype.RegExpTable["oncertificatedialog"]=".*";MacroPlayer.prototype.ActionTable["oncertificatedialog"]=function(cmd){throw new UnsupportedCommand("ONCERTIFICATEDIALOG");};MacroPlayer.prototype.RegExpTable["ondialog"]="^pos\\s*=\\s*(\\S+)"+"\\s+button\\s*=\\s*(\\S+)"+"(?:\\s+content\\s*=\\s*("+im_strre+")?)?\\s*$";MacroPlayer.prototype.ActionTable["ondialog"]=function(cmd){var pos=__int(unwrapLine(mplayer.expandVariables(cmd[1])));if(isNaN(pos))throw new BadParameter("POS=<number>",1);var button=unwrapLine(mplayer.expandVariables(cmd[2]));var storage=getiMacrosStorage();var obj=new Object();obj.accept=/^(ok|yes)$/i.test(button);if(typeof cmd[3]!="undefined")obj.content=unwrapLine(mplayer.expandVariables(cmd[3]));obj.timeout=mplayer.delay;storage.setObjectForWindow(window.im_wid,"onDialogAction",obj);};MacroPlayer.prototype.RegExpTable["ondownload"]="^folder\\s*=\\s*(\\S*)\\s+"+"file\\s*=\\s*("+im_strre+")"+"(?:\\s+wait\\s*=(yes|no|true|false))?"+"(?:\\s+checksum\\s*=(md5|sha1):(\\S+))?"+"\\s*$";MacroPlayer.prototype.ActionTable["ondownload"]=function(cmd){var storage=getiMacrosStorage();var obj=new Object();var wait=true;var folder=unwrapLine(mplayer.expandVariables(cmd[1]));var file=unwrapLine(mplayer.expandVariables(cmd[2]));obj.accept=true;if(folder!="*"){try{var f=im_FIO.openNode(folder);if(!f.exists())im_FIO.makeDirectory(folder);}catch(e){var reason="";if(/ACCESS_DENIED/.test(e.toString()))reason=" access denied";throw new RuntimeError("can not open ONDOWNLOAD folder: '"+folder+"'"+reason,932);}}obj.folder=folder;obj.filename=file;obj.timeout=mplayer.delay;storage.setObjectForWindow(window.im_wid,"onDownloadAction",obj);if(typeof cmd[3]!="undefined"){var param=unwrapLine(mplayer.expandVariables(cmd[3]));wait=/^(?:yes|true)$/i.test(param);}mplayer.shouldWaitDownload=wait;mplayer.downloadFolder=folder;mplayer.downloadFilename=file;if(typeof cmd[4]!="undefined"){if(!wait){throw new BadParameter("CHECKSUM requires WAIT=YES",3);}mplayer.downloadCheckAlg=unwrapLine(mplayer.expandVariables(cmd[4]));mplayer.downloadChecksum=unwrapLine(mplayer.expandVariables(cmd[5])).toLowerCase();}else{mplayer.downloadChecksum=mplayer.downloadCheckAlg="";}};MacroPlayer.prototype.calculateFileHash=function(file,alg){var istream=imns.Cc["@mozilla.org/network/file-input-stream;1"].createInstance(imns.Ci.nsIFileInputStream);istream.init(file,0x01,0444,0);var ch=imns.Cc["@mozilla.org/security/hash;1"].createInstance(imns.Ci.nsICryptoHash);var hash_alg;alg=alg.toUpperCase();if(alg=="MD5"){hash_alg=ch.MD5;}else if(alg=="SHA1"){hash_alg=ch.SHA1;}else{throw new RuntimeError("Unknown Hash algorithm "+alg);}ch.init(hash_alg);const PR_UINT32_MAX=0xffffffff;ch.updateFromStream(istream,PR_UINT32_MAX);var hash=ch.finish(false);function tohex(charCode){return("0"+charCode.toString(16)).slice(-2);};var s=[tohex(hash.charCodeAt(i))for(i in hash)].join("");return s.toLowerCase();};MacroPlayer.prototype.handleOnDownloadFile=function(uri,folder,filename){var leafName="",m=null;if(m=uri.match(/\/([^\/?]+)(?=\?.+|$)/)){leafName=m[1];}else{leafName=content.document.title;}if(filename=="*"){filename=leafName;}else if(m=filename.match(/^\+(.*)$/)){if(/\..+$/.test(leafName))filename=leafName.replace(/(.+)(\..+)$/,"$1"+m[1]+"$2");else filename=leafName+m[1];}var file;if(folder=="*"){file=im_Pref.getFilePref("defdownpath");}else{file=im_FIO.openNode(folder);}file.append(filename);return file;};MacroPlayer.prototype.saveURI=function(uri,file,wait){var wbp=imns.Cc['@mozilla.org/embedding/browser/nsWebBrowserPersist;1'];wbp=wbp.createInstance(imns.Ci.nsIWebBrowserPersist);var flags=wbp.PERSIST_FLAGS_REPLACE_EXISTING_FILES;wbp.persistFlags=flags;if(wait){wbp.progressListener={onProgressChange:function(){},onStateChange:function(web_progress,request,state,status){if(state&imns.Ci.nsIWebProgressListener.STATE_START){}else if(state&imns.Ci.nsIWebProgressListener.STATE_STOP){if(mplayer.downloadChecksum){try{var check=mplayer.calculateFileHash(file,mplayer.downloadCheckAlg);if(check!=mplayer.downloadChecksum){mplayer.errorCode= -934;mplayer.errorMessage="RuntimeError: "+"Checksum of downloaded file "+check+" doesn't match specified";im_panel.showErrorMessage(mplayer.errorMessage,mplayer.errorCode);if(!mplayer.ignoreErrors)mplayer.stop();mplayer.downloadChecksum="";mplayer.downloadCheckAlg="";}}catch(e){mplayer.errorCode= -1;mplayer.errorMessage=e.toString();im_panel.showErrorMessage(mplayer.errorMessage,mplayer.errorCode);if(!mplayer.ignoreErrors)mplayer.stop();}}setTimeout(function(){mplayer.playNextAction()},0);}}};}wbp.saveURI(uri,null,null,null,"",file);};MacroPlayer.prototype.saveTargetAs=function(element){var e=element;while(e&&e.nodeType==Node.ELEMENT_NODE&& !(e.hasAttribute("href")||e.hasAttribute("src")))e=e.parentNode;if(!e||e.nodeType!=Node.ELEMENT_NODE)throw new RuntimeError("can not find link to save target",923);var link=e.hasAttribute("href")?e.href:e.src;var file=this.handleOnDownloadFile(link,this.downloadFolder,this.downloadFilename);var ios=imns.Cc["@mozilla.org/network/io-service;1"].getService(imns.Ci.nsIIOService);var uri=ios.newURI(link,null,null);this.saveURI(uri,file,mplayer.shouldWaitDownload);delete mplayer.downloadFolder;delete mplayer.downloadFilename;};MacroPlayer.prototype.savePictureAs=function(element){if(!element.hasAttribute("src"))throw new RuntimeError("can not save picture: no src attribute found "+" for element "+element.tagName,923);var file=this.handleOnDownloadFile(element.src,this.downloadFolder,this.downloadFilename);var ios=imns.Cc["@mozilla.org/network/io-service;1"].getService(imns.Ci.nsIIOService);var uri=ios.newURI(element.src,null,null);this.saveURI(uri,file,mplayer.shouldWaitDownload);delete mplayer.downloadFolder;delete mplayer.downloadFilename;};MacroPlayer.prototype.RegExpTable["onerrordialog"]="^(?:button\\s*=\\s*(?:\\S*))?\\s*(?:\\bcontinue\\s*=\\s*(\\S*))?\\s*$";MacroPlayer.prototype.ActionTable["onerrordialog"]=function(cmd){var param=cmd[1]?unwrapLine(mplayer.expandVariables(cmd[1])):"";if(/^no|false$/i.test(param)){mplayer.shouldStopOnError=true;var dummyPlayer=getJSPlayer();}};MacroPlayer.prototype.RegExpTable["onlogin"]="^user\\s*=\\s*("+im_strre+")\\s+"+"password\\s*=\\s*("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["onlogin"]=function(cmd){var storage=getiMacrosStorage();var pm=getiMacrosPM();var obj=new Object(),key=getEncryptionKey();var username=unwrapLine(mplayer.expandVariables(cmd[1]));var password=unwrapLine(mplayer.expandVariables(cmd[2]));obj.accept=true;obj.username=username;if(pm.encryptionType!=pm.TYPE_NONE){try{obj.password=Rijndael.decryptString(password,getEncryptionKey());}catch(e){var param={reenter:true,password:"",master:pm.encryptionType==pm.TYPE_STORED};window.openDialog('chrome://imacros/content/keydlg4.xul','','modal,centerscreen',param);if(param.master){pm.setMasterPwd(param.password);pm.encryptionType=pm.TYPE_STORED;}else{pm.setSessionPwd(param.password);pm.encryptionType=pm.TYPE_TEMP;}obj.password=Rijndael.decryptString(password,param.password);}}else{obj.password=password;}obj.timeout=mplayer.delay;storage.setObjectForWindow(window.im_wid,"onDialogAction",obj);};MacroPlayer.prototype.RegExpTable["onprint"]=".*";MacroPlayer.prototype.ActionTable["onprint"]=function(cmd){throw new UnsupportedCommand("ONPRINT");};MacroPlayer.prototype.RegExpTable["onsecuritydialog"]=".*";MacroPlayer.prototype.ActionTable["onsecuritydialog"]=function(cmd){throw new UnsupportedCommand("ONSECURITYDIALOG");};MacroPlayer.prototype.RegExpTable["onwebpagedialog"]=".*";MacroPlayer.prototype.ActionTable["onwebpagedialog"]=function(cmd){throw new UnsupportedCommand("ONWEBPAGEDIALOG");};MacroPlayer.prototype.RegExpTable["pause"]="^\\s*$";MacroPlayer.prototype.ActionTable["pause"]=function(cmd){imacrose="playing";mplayer.pause();im_panel.updateSidebarState();};MacroPlayer.prototype.RegExpTable["print"]=".*";MacroPlayer.prototype.ActionTable["print"]=function(cmd){throw new UnsupportedCommand("PRINT");};MacroPlayer.prototype.RegExpTable["prompt"]="^("+im_strre+")"+"(?:\\s+!var([123])"+"(?:\\s+("+im_strre+"))?)?\\s*$";MacroPlayer.prototype.ActionTable["prompt"]=function(cmd){var text=unwrapLine(mplayer.expandVariables(cmd[1]));var defval=cmd[3]?unwrapLine(mplayer.expandVariables(cmd[3])):"";var prompts=imns.Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(imns.Ci.nsIPromptService);if(typeof cmd[2]!="undefined"){var check={value:false};var input={value:defval};var result=prompts.prompt(window,"iMacros",text,input,null,check);if(result){mplayer.vars[__int(cmd[2])]=input.value;}}else{prompts.alert(window,"iMacros",text);}};MacroPlayer.prototype.RegExpTable["proxy"]=".*";MacroPlayer.prototype.ActionTable["proxy"]=function(cmd){throw new UnsupportedCommand("PROXY");};MacroPlayer.prototype.RegExpTable["redial"]=".*";MacroPlayer.prototype.ActionTable["redial"]=function(cmd){throw new UnsupportedCommand("REDIAL");};MacroPlayer.prototype.RegExpTable["refresh"]="^\\s*$";MacroPlayer.prototype.ActionTable["refresh"]=function(cmd){getWebNavigation().reload(imns.Ci.nsIWebNavigation.LOAD_FLAGS_NONE);};MacroPlayer.prototype.RegExpTable["saveas"]="^type\\s*=\\s*(\\S+)\\s+"+"folder\\s*=\\s*("+im_strre+")\\s+"+"file\\s*=\\s*("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["saveas"]=function(cmd){var folder=unwrapLine(mplayer.expandVariables(cmd[2]));var type=unwrapLine(mplayer.expandVariables(cmd[1])).toLowerCase();if(folder=="*"){folder=im_Pref.getFilePref("defdownpath").path;}try{var f=im_FIO.openNode(folder);}catch(e){throw new RuntimeError("Wrong path "+folder,932);}if(!f.exists())throw new RuntimeError("Path "+folder+" does not exists",932);var file=unwrapLine(mplayer.expandVariables(cmd[3])),t;var __doc_name=function(win){var name=win.location.pathname;if(/\/([^/]*)$/.test(name));name=RegExp.$1;if(!name.length)name=win.document.title;if(!name.length)return "unknown";if(/^(.*)\.(?:\w+)$/.test(name))return RegExp.$1;return name;};if(file=="*"){file=__doc_name(content);}else if(t=file.match(/^\+(.+)$/)){file=__doc_name(content)+t[1];}var re=new RegExp('\\s*[:*?|<>\\"/]+\\s*',"g");file=file.replace(re,"_");if(type=="extract"){if(file=="*")file="extract.csv";var data=mplayer.getExtractData();mplayer.clearExtractData();data=data.replace(/\"/g,'""');data='"'+data.replace(/\[EXTRACT\]/g,'","')+'"';f=im_FIO.openNode(folder);f.append(file);im_FIO.appendTextFile(f,data+"\r\n");}else{var wbp=null,doc=window.content.document;wbp=imns.Cc['@mozilla.org/embedding/browser/nsWebBrowserPersist;1'];wbp=wbp.createInstance(imns.Ci.nsIWebBrowserPersist);var flags=wbp.PERSIST_FLAGS_REPLACE_EXISTING_FILES;wbp.persistFlags=flags;var f=im_FIO.openNode(folder);if(type=="cpl"){if(!/html?$/.test(file))file+=".htm";f.append(file);var files_dir=f.path.replace(/\.html?$/,"_files");files_dir=im_FIO.openNode(files_dir);wbp.saveDocument(doc,f,files_dir,null,null,0);}else if(type=="htm"){if(!/html?$/.test(file))file+=".htm";f.append(file);wbp.saveDocument(doc,f,null,null,null,0);}else if(type=="txt"){f.append(file);wbp.saveDocument(doc,f,null,"text/plain",wbp.ENCODE_FLAGS_FORMAT_FLOWED,0);}else if(/^png|jpeg$/.test(type)){mplayer.savePageAsImage(window.content,file,f,type);}else{throw new BadParameter("iMacros for Firefox supports only "+"CPL|HTM|TXT|EXTRACT|PNG|JPEG SAVEAS types");}}};MacroPlayer.prototype.savePageAsImage=function(win,filename,folder,type){var canvasW=win.innerWidth+win.scrollMaxX;var canvasH=win.innerHeight+win.scrollMaxY;if(canvasW>10000)canvasW=10000;if(canvasH>10000)canvasH=10000;var canvas=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");canvas.style.width=canvasW+"px";canvas.style.height=canvasH+"px";canvas.width=canvasW;canvas.height=canvasH;var ctx=canvas.getContext("2d");ctx.clearRect(0,0,canvasW,canvasH);ctx.save();ctx.drawWindow(win,0,0,canvasW,canvasH,"rgb(0,0,0)");ctx.restore();var content_type,param;if(type=="jpeg"){content_type="image/jpeg";param="quality=100";if(!/\.jpe?g$/.test(filename))filename=/\.\w+$/.test(filename)?filename.replace(/\.\w+$/,".jpg"):filename+".jpg";}else if(type=="png"){content_type="image/png";param="";if(!/\.png$/.test(filename))filename=/\.\w+$/.test(filename)?filename.replace(/\.\w+$/,".png"):filename+".png";}else{return;}var file=folder.clone();file.append(filename);var ios=imns.Cc["@mozilla.org/network/io-service;1"].getService(imns.Ci.nsIIOService);var source=ios.newURI(canvas.toDataURL(content_type,param),"UTF8",null);var target=ios.newFileURI(file);var wbp=imns.Cc['@mozilla.org/embedding/browser/nsWebBrowserPersist;1'];wbp=wbp.createInstance(imns.Ci.nsIWebBrowserPersist);var flags=wbp.PERSIST_FLAGS_REPLACE_EXISTING_FILES|wbp.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;wbp.persistFlags=flags;wbp.saveURI(source,null,null,null,null,file);};MacroPlayer.prototype.RegExpTable["set"]="^!(\\S+)\\s+("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["set"]=function(cmd){var param=unwrapLine(mplayer.expandVariables(cmd[2]));switch(cmd[1].toLowerCase()){case "encryption":var pm=getiMacrosPM();switch(param.toLowerCase()){case "no":pm.encryptionType=pm.TYPE_NONE;break;case "storedkey":case "yes":pm.encryptionType=pm.TYPE_STORED;break;case "tmpkey":pm.encryptionType=pm.TYPE_TEMP;break;default:throw new BadParameter("!ENCRYPTION can be only "+"YES|NO|STOREDKEY|TMPKEY");}break;case "imagefilter":mplayer.shouldFilterImages=/^on$/i.test(param);break;case "downloadpdf":mplayer.shouldDownloadPDF=/^yes$/i.test(param);break;case "useragent":try{var storage=getiMacrosStorage();var branch=imns.prefsvc.getBranch("general.useragent.");var useragent_override=new Object();if(branch.prefHasUserValue("override")){useragent_override.value=branch.getCharPref("override");}branch.setCharPref("override",param);storage.setNamedObject("useragent_override",useragent_override);}catch(e){Components.utils.reportError(e);}break;case "loop":if(mplayer.firstLoop){if(isNaN(__int(param)))throw new BadParameter("!LOOP must be integer");mplayer.currentLoop=__int(param);im_panel.currentLoopValue=mplayer.currentLoop;}break;case "extract":mplayer.clearExtractData();if(!/^null$/i.test(param))mplayer.addExtractData(param);break;case "extractadd":mplayer.addExtractData(param);break;case "extract_test_popup":mplayer.shouldPopupExtract=/^yes$/i.test(param);break;case "errorignore":mplayer.ignoreErrors=/^yes$/i.test(param);break;case "filestopwatch":var filename=param,file;if(filename.indexOf(__psep())!= -1){var file=im_FIO.openNode(filename);if(!file.parent&&file.parent.exists())throw new RuntimeError("Path "+file.parent.path+" does not exists",932);}else{file=im_Pref.getFilePref("defdownpath");file.append(filename);}try{im_FIO.appendTextFile(file,"");}catch(e){var reason="";if(/ACCESS_DENIED/.test(e.toString()))reason=", access denied";throw new RuntimeError("can not write to STOPWATCH file: "+file.path+reason,931);}mplayer.stopwatchFile=file.clone();break;case "folder_stopwatch":try{mplayer.stopwatchFolder=im_FIO.openNode(param);if(!mplayer.stopwatchFolder.isWritable()){throw new RuntimeError("can not write to STOPWATCH folder: "+"access denied",931);}}catch(e){throw new RuntimeError("can not open STOPWATCH folder: "+param,931);}break;case "datasource":mplayer.loadDataSource(param);break;case "datasource_line":var x=__int(param);if(isNaN(x)||x<=0)throw new BadParameter("!DATASOURCE_LINE must be positive integer");if(mplayer.dataSource.length<x)throw new RuntimeError("Invalid DATASOURCE_LINE value: "+param,951);mplayer.dataSourceLine=x;break;case "datasource_columns":if(isNaN(__int(param)))throw new BadParameter("!DATASOURCE_COLUMNS must be integer");mplayer.dataSourceColumns=__int(param);break;case "timeout":case "timeout_page":var x=__int(param);if(isNaN(x)||x<=0)throw new BadParameter("!TIMEOUT must be positive integer");mplayer.timeout=x;break;case "timeout_macro":var x=parseFloat(param);if(isNaN(x)||x<=0)throw new BadParameter("!TIMEOUT_MACRO must be positive number");mplayer.globalTimer.setMacroTimeout(x);break;case "timeout_tag":var x=__int(param);if(isNaN(x)||x<=0)throw new BadParameter("!TIMEOUT_TAG must be positive integer");mplayer.tagTimeout=x;break;case "replayspeed":switch(param.toLowerCase()){case "slow":mplayer.delay=2000;break;case "medium":mplayer.delay=1000;break;case "fast":mplayer.delay=0;break;default:throw new BadParameter("!REPLAYSPEED can be SLOW|MEDIUM|FAST");}break;case "singlestep":mplayer.singleStepMode=/yes/i.test(param);break;case "clipboard":im_Clipboard.putString(param);break;case "linenumber_delta":var x=__int(param);if(isNaN(x))throw new BadParameter("!LINENUMBER_DELTA must be integer");mplayer.linenumber_delta=x;break;case "x_fx_clickmode":if(!/^(?:api|dom)/i.test(param))throw new BadParameter("!X_FX_CLICKMODE can be API|DOM");mplayer.clickmode=param.toLowerCase();break;default:if(/^var([123])$/i.test(cmd[1]))mplayer.vars[__int(RegExp.$1)]=param;else throw new BadParameter("Wrong variable "+cmd[1]);}};MacroPlayer.prototype.globalTimer={init:function(){if(this.macroTimeout){clearTimeout(this.macroTimeout);this.macroTimeout=null;}},start:function(){this.startTime=new Date();},getElapsedTime:function(){if(!this.startTime)return 0;var now=new Date();return(now.getTime()-this.startTime.getTime())/1000;},setMacroTimeout:function(x){this.macroTimeout=setTimeout(function(){mplayer.errorCode= -803;mplayer.errorMessage="RuntimeError: "+"Max. macro runtime was reached. Macro stopped.";mplayer.stop();im_panel.showErrorMessage(mplayer.errorMessage,mplayer.errorCode);},Math.round(x*1000));},stop:function(){if(this.macroTimeout){clearTimeout(this.macroTimeout);this.macroTimeout=null;}}};MacroPlayer.prototype.RegExpTable["size"]=".*";MacroPlayer.prototype.ActionTable["size"]=function(cmd){throw new UnsupportedCommand("SIZE");};MacroPlayer.prototype.RegExpTable["stopwatch"]="^((?:(start|stop)\\s+)?id|label)\\s*=\\s*("+im_strre+")\\s*$";MacroPlayer.prototype.addTimeWatch=function(name){this.watchTable[name]=this.globalTimer.getElapsedTime();};MacroPlayer.prototype.stopTimeWatch=function(name){if(typeof this.watchTable[name]=="undefined")throw new RuntimeError("time watch "+name+" does not exist",962);var elapsed=this.globalTimer.getElapsedTime()-this.watchTable[name];this.lastWatchValue=elapsed;var x={id:name,type:"id",elapsedTime:elapsed};this.stopwatchResults.push(x);};MacroPlayer.prototype.addTimeWatchLabel=function(name){var elapsed=this.globalTimer.getElapsedTime();this.lastWatchValue=elapsed;var x={id:name,type:"label",elapsedTime:elapsed};this.stopwatchResults.push(x);};MacroPlayer.prototype.ActionTable["stopwatch"]=function(cmd){var action=cmd[2]?cmd[2].toLowerCase():null;var use_label=/label$/i.test(cmd[1]);var param=unwrapLine(mplayer.expandVariables(cmd[3]));param=param.toUpperCase();if(!use_label){var found=typeof mplayer.watchTable[param]!="undefined";switch(action){case "start":if(found)throw new RuntimeError("stopwatch id="+param+" already started");mplayer.addTimeWatch(param);break;case "stop":if(!found)throw new RuntimeError("stopwatch id="+param+" wasn't started");mplayer.stopTimeWatch(param);break;default:if(found)mplayer.stopTimeWatch(param);else mplayer.addTimeWatch(param);break;}}else{mplayer.addTimeWatchLabel(param);}};MacroPlayer.prototype.RegExpTable["tab"]="^(t\\s*=\\s*(\\S+)|"+"close|closeallothers|open|open\\s+new|new\\s+open"+")\\s*$";MacroPlayer.prototype.ActionTable["tab"]=function(cmd){var browser=getBrowser();if(/^close$/i.test(cmd[1])){browser.removeCurrentTab();}else if(/^closeallothers$/i.test(cmd[1])){browser.removeAllTabsBut(browser.selectedTab);mplayer.startTabIndex=0;}else if(/open/i.test(cmd[1])){browser.addTab();}else if(/^t\s*=/i.test(cmd[1])){var n=__int(mplayer.expandVariables(cmd[2]));if(isNaN(n))throw new BadParameter("T=<number>",1);var tab_num=n+mplayer.startTabIndex-1;var tabs=browser.tabContainer.childNodes;if(tab_num>=0&&tab_num<tabs.length){browser.selectedTab=tabs[tab_num];}else{throw new RuntimeError("Tab number "+(tab_num+1)+" does not exist",971);}}mplayer.currentWindow=window.content;};var TagHandler={escapeChars:function(str){var chars="^$.+?=!:|\\/()[]{}",res="",i,j;for(i=0;i<str.length;i++){for(j=0;j<chars.length;j++){if(str[i]==chars[j]){res+="\\";break;}}res+=str[i];}return res;},parseAtts:function(str){if(!str||str=="*")return null;var arr=str.split(new RegExp("&&(?=[-\\w]+:"+im_strre+")"));var atts=new Object(),at,val,m;const re=new RegExp("^([-\\w]+):("+im_strre+")$");for(var i=0;i<arr.length;i++){if(!(m=re.exec(arr[i])))throw new BadParameter("incorrect ATTR or FORM specifier: "+arr[i]);at=m[1].toLowerCase();if(at.length){val=unwrapLine(mplayer.expandVariables(m[2]));val=escapeTextContent(val);val=this.escapeChars(val).replace(/\*/g,'(?:\n|.)*');val=val.replace(/ /g,"\\s+");atts[at]=new RegExp("^\\s*"+val+"\\s*$");}else{atts[at]=new RegExp("^$");}}return atts;},match:function(node,atts){var match=true;for(var at in atts){if(at=="txt"){var txt=escapeTextContent(node.textContent);if(!atts[at].exec(txt)){match=false;break;}}else{var atval="",propval="";if(at in node){propval=node[at];}else if(at=="href"&&"src"in node){propval=node.src;}if(node.hasAttribute(at)){atval=node.getAttribute(at);}if(!(! !atts[at].exec(propval)|| ! !atts[at].exec(atval))){match=false;break;}}}return match;},find:function(doc,root,pos,relative,tagName,atts,form_atts){var xpath="descendant-or-self",ctx=root,nodes=new Array();if(relative){xpath=pos>0?"following":"preceding";if(!(ctx=this.lastNode)||ctx.ownerDocument!=doc)return(this.lastNode=null);}if(tagName=="*"){xpath+="::*";}else{xpath+="::*[translate(local-name(),"+"'ABCDEFGHIJKLMNOPQRSTUVWXYZ',"+"'abcdefghijklmnopqrstuvwxyz')='"+tagName.toLowerCase()+"']";}try{var result=doc.evaluate(xpath,ctx,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var node=null;while(node=result.iterateNext()){nodes.push(node);}}catch(e){Components.utils.reportError(e);}var count=0,i,start,end,increment;if(pos>0){start=0;end=nodes.length;increment=1;}else if(pos<0){start=nodes.length-1;end= -1;increment= -1;}else{throw new BadParameter("POS=<number> or POS=R<number>"+" where <number> is a non-zero integer",1);}if(form_atts&&form_atts["name"]&&form_atts["name"].exec("NoFormName"))form_atts=null;for(i=start;i!=end;i+=increment){var match=atts?this.match(nodes[i],atts):true;if(match&&form_atts&&nodes[i].form)match=this.match(nodes[i].form,form_atts);if(match&& ++count==Math.abs(pos)){return(this.lastNode=nodes[i]);}}return(this.lastNode=null);},findByXPath:function(doc,root,xpath){var nodes=new Array();try{var result=doc.evaluate(xpath,root,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var node=null;while(node=result.iterateNext()){nodes.push(node);}}catch(e){Components.utils.reportError(e);throw new RuntimeError("incorrect XPath expression: "+xpath,981);}if(nodes.length>1)throw new RuntimeError("unambiguous XPath expression: "+xpath,982);if(nodes.length==1)return nodes[0];return null;},findPosition:function(element,atts,form_atts){var xpath="descendant-or-self::*[translate(local-name(),"+"'ABCDEFGHIJKLMNOPQRSTUVWXYZ',"+"'abcdefghijklmnopqrstuvwxyz')='"+element.tagName.toLowerCase()+"']";var doc=element.ownerDocument;var ctx=doc.documentElement;var nodes=new Array(),count=0;try{var res=doc.evaluate(xpath,ctx,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var node=null;while(node=res.iterateNext()){nodes.push(node);}}catch(e){Components.utils.reportError(e);}if(form_atts&&form_atts["name"]&&form_atts["name"].exec("NoFormName"))form_atts=null;for(var i=0;i<nodes.length;i++){var match=atts?this.match(nodes[i],atts):true;if(match&&form_atts&&nodes[i].form)match=this.match(nodes[i].form,form_atts);if(match)count++;if(nodes[i]==element)break;}return count;},getOuterHTML:function(node){if(!node)return;var doc=node.ownerDocument;var div=doc.createElement("div");div.appendChild(node.cloneNode(true));var s=div.innerHTML;div.innerHTML="";return s;},onExtractParam:function(tagName,element,extract_type){var tmp="",i;if(/^(txt|txtall)$/i.test(extract_type)){tmp=RegExp.$1.toLowerCase();switch(tagName){case "input":case "textarea":mplayer.showAndAddExtractData(element.value);break;case "select":if(tmp=="txtall"){var s=new Array(),options=element.options;for(i=0;i<options.length;i++){s.push(options[i].text);}mplayer.showAndAddExtractData(s.join("[OPTION]"));}else{var s=element.options[element.selectedIndex].text;mplayer.showAndAddExtractData(s);}break;case "table":tmp="";for(i=0;i<element.rows.length;i++){var row=element.rows[i],ar=new Array();for(var j=0;j<row.cells.length;j++)ar.push(row.cells[j].textContent);tmp+='"'+ar.join('","')+'"\n';}mplayer.showAndAddExtractData(tmp);break;default:mplayer.showAndAddExtractData(element.textContent);}}else if(/^htm$/i.test(extract_type)){tmp=this.getOuterHTML(element);tmp=tmp.replace(/[\t\n\r]/g," ");mplayer.showAndAddExtractData(tmp);}else if(/^href$/i.test(extract_type)){if("href"in element)mplayer.showAndAddExtractData(element["href"]);else if(element.hasAttribute("href"))mplayer.showAndAddExtractData(elem.getAttribute("href"));else if("src"in element)mplayer.showAndAddExtractData(element["src"]);else if(element.hasAttribute("src"))mplayer.showAndAddExtractData(elem.getAttribute("src"));else mplayer.showAndAddExtractData("#EANF#");}else if(/^(title|alt)$/i.test(extract_type)){tmp=RegExp.$1.toLowerCase();if(tmp in element)mplayer.showAndAddExtractData(element[tmp]);else if(element.hasAttribute(tmp))mplayer.showAndAddExtractData(elem.getAttribute(tmp));else mplayer.showAndAddExtractData("#EANF#");}else if(/^checked$/i.test(extract_type)){if(!/^(?:checkbox|radio)$/i.test(element.type))throw new BadParameter("EXTRACT=CHECKED makes sense"+" only for check or radio boxes");mplayer.showAndAddExtractData(element.checked?"YES":"NO");}else{throw new BadParameter("EXTRACT=TXT|TXTALL|HTM|"+"TITLE|ALT|HREF|CHECKED",5);}},onContentParam:function(tagName,element,content){var tmp;this.htmlFocusEvent(element);switch(tagName){case "select":this.handleSelectElement(element,content);this.htmlChangeEvent(element);break;case "input":if(content)content=unwrapLine(mplayer.expandVariables(content));switch(element.type){case "text":case "hidden":element.value=content;this.htmlChangeEvent(element);break;case "password":this.handlePasswordElement(element,content);this.htmlChangeEvent(element);break;case "checkbox":if(/^(?:true|yes|on)$/i.test(content)){if(!element.checked)element.click();}else{if(element.checked)element.click();}break;case "file":element.value=content;this.htmlChangeEvent(element);break;default:this.simulateClick(element);}break;case "button":this.simulateClick(element);break;case "textarea":if(content)content=unwrapLine(mplayer.expandVariables(content));element.value=content;this.htmlChangeEvent(element);break;default:this.simulateClick(element);}this.htmlBlurEvent(element);},handleSelectElement:function(element,content){const re=new RegExp("^(?:([%$])"+im_strre+")(?::\\1"+im_strre+")*$");const idx_re=new RegExp("^(#?)\\d+(?::\\1\\d+)*$");var m,split_re;if(m=content.match(re)){var non_delimeter="(?:\"(?:[^\"\\\\]|\\\\[0btnvfr\"\'\\\\])*\"|(?:[^:\\s]|:[^"+m[1]+"])+)";split_re=new RegExp("(\\"+m[1]+non_delimeter+")","g");}else if(m=content.match(idx_re)){split_re=new RegExp("(#?\\d+)","g");}else{throw new RuntimeError("Wrong format of CONTENT value");}var g,opts=new Array();while(g=split_re.exec(content)){opts.push(g[1]);}var options=element.options;element.options.selectedIndex= -1;if(opts.length>1)element.multiple=true;for(var i=0;i<opts.length;i++){if(/^#?(\d+)$/.test(opts[i])){var idx=__int(RegExp.$1);if(idx>element.length&& !mplayer.ignoreErrors)throw new RuntimeError("Selected entry not available:"+idx+" [Box has "+element.length+" entries]",924);options[idx-1].selected=true;}else if(/^([%$])(.*)$/i.test(opts[i])){var typ=RegExp.$1,found=false;var val=unwrapLine(mplayer.expandVariables(RegExp.$2));val=this.escapeChars(val).replace(/\*/g,'(?:\n|.)*');val=new RegExp("^\\s*"+val+"\\s*$","i");for(var j=0;j<options.length;j++){var o=options[j];if(val.exec(typ=="$"?o.textContent:o.value)){found=true;options[j].selected=true;break;}}if(!found&& !mplayer.ignoreErrors){throw new RuntimeError("Selected entry not available: '"+opts[i]+"' [Box has "+options.length+" entries]",924);}}else if(/^all$/i.test(content)){for(var i=0;i<options.length;i++)options[i].selected=true;}else{throw new RuntimeError("Unable to select entry specified by: "+content,925);}}},handlePasswordElement:function(element,content){var data="",pm=getiMacrosPM();if(pm.encryptionType!=pm.TYPE_NONE){try{data=Rijndael.decryptString(content,getEncryptionKey());}catch(e){var param={reenter:true,password:"",master:pm.encryptionType==pm.TYPE_STORED};window.openDialog('chrome://imacros/content/keydlg4.xul','','modal,centerscreen',param);if(param.master){pm.setMasterPwd(param.password);pm.encryptionType=pm.TYPE_STORED;}else{pm.setSessionPwd(param.password);pm.encryptionType=pm.TYPE_TEMP;}data=Rijndael.decryptString(content,param.password);}}else{data=content;}element.value=data;},simulateClick:function(element){if(element.click){element.click();return;}var useDOMClick;switch(mplayer.clickmode){case "dom":useDOMClick=true;break;case "api":useDOMClick=false;break;}if("nsIDOMWindowUtils"in imns.Ci&& !useDOMClick){var win=element.ownerDocument.defaultView;var req=win.QueryInterface(imns.Ci.nsIInterfaceRequestor);var utils=req.getInterface(imns.Ci.nsIDOMWindowUtils);var pos=ClickHandler.findElementPosition(element);var x=pos.x-win.scrollX,y=pos.y-win.scrollY;utils.sendMouseEvent("mouseover",x,y,0,0,0,true);utils.sendMouseEvent("mousedown",x,y,0,1,0,true);utils.sendMouseEvent("mouseup",x,y,0,1,0,true);}else{var initEvent=function(e,d,typ){e.initMouseEvent(typ,true,true,d.defaultView,1,0,0,0,0,false,false,false,false,0,null);};var stop=function(e){e.stopPropagation();};var doc=element.ownerDocument,x;var events={"mouseover":null,"mousedown":null,"mouseup":null,"click":null};element.addEventListener("mouseover",stop,false);element.addEventListener("mouseout",stop,false);for(x in events){events[x]=doc.createEvent("MouseEvent");initEvent(events[x],doc,x);element.dispatchEvent(events[x]);}}},htmlChangeEvent:function(element){if(!/^(?:input|select|textarea)$/i.test(element.tagName))return;var evt=element.ownerDocument.createEvent("Event");evt.initEvent("change",true,false);element.dispatchEvent(evt);},htmlFocusEvent:function(element){if(!/^(?:a|area|label|input|select|textarea|button)$/i.test(element.tagName))return;var evt=element.ownerDocument.createEvent("Event");evt.initEvent("focus",false,false);element.dispatchEvent(evt);},htmlBlurEvent:function(element){if(!/^(?:a|area|label|input|select|textarea|button)$/i.test(element.tagName))return;var evt=element.ownerDocument.createEvent("Event");evt.initEvent("blur",false,false);element.dispatchEvent(evt);}};const im_atts_re="(?:[-\\w]+:"+im_strre+"(?:&&[-\\w]+:"+im_strre+")*|\\*?)";MacroPlayer.prototype.RegExpTable["tag"]="^(?:pos\\s*=\\s*(\\S+)\\s+"+"type\\s*=\\s*(\\S+)"+"(?:\\s+form\\s*=\\s*("+im_atts_re+"))?\\s+"+"attr\\s*=\\s*("+im_atts_re+")"+"|xpath\\s*=\\s*("+im_strre+"))"+"(?:\\s+(content|extract)\\s*=\\s*"+"(\\d+(?::\\d+)*|"+"[%$]"+im_strre+"(?::[%$]"+im_strre+")*|"+im_strre+"))?\\s*$";MacroPlayer.prototype.ActionTable["tag"]=function(cmd){var pos=0;var relative=false;var tagName="";var form=null,atts=null;var xpath=null;var txt=cmd[6]?cmd[7]:null;var type=cmd[6]?cmd[6].toLowerCase():"";if(cmd[5]){xpath=unwrapLine(mplayer.expandVariables(cmd[5]));}else{pos=unwrapLine(mplayer.expandVariables(cmd[1])),relative;tagName=unwrapLine(mplayer.expandVariables(cmd[2])).toLowerCase();form=TagHandler.parseAtts(cmd[3]);atts=TagHandler.parseAtts(cmd[4]);if(/^r(-?\d+)$/i.test(pos)){pos=__int(RegExp.$1);relative=true;}else if(/^(\d+)$/.test(pos)){pos=__int(RegExp.$1);relative=false;}else{throw new BadParameter("POS=<number> or POS=R<number>"+"where <number> is a non-zero integer",1);}if(/^(\S+):(\S+)$/i.test(tagName)){if(!atts)atts=new Object();var val=RegExp.$2;tagName=RegExp.$1.toLowerCase();val=TagHandler.escapeChars(val).replace(/\*/g,'(?:\n|.)*');atts["type"]=new RegExp("^"+val+"$");}}var doc=mplayer.currentWindow.document;var root=doc.documentElement;var timeout=mplayer.tagTimeout||mplayer.timeout/10;if(!mplayer.playingAgain){mplayer.nattempts=Math.round(timeout);if(!mplayer.nattempts)mplayer.nattempts=1;var element=null;}while(mplayer.nattempts--){element=xpath?TagHandler.findByXPath(doc,root,xpath):TagHandler.find(doc,root,pos,relative,tagName,atts,form);if(element){try{mplayer.processElement(element,type,txt);break;}catch(e){if(e.message&&/^Selected entry not/.test(e.message)&&mplayer.nattempts){;}else{throw e;}}}im_panel.statLine2Status="loading";imns.osvc.notifyObservers(window,"imacros-delay-show","Tag waiting... "+mplayer.nattempts+"("+Math.round(timeout)+")s");throw new ShouldWaitSignal(true,1000);}im_panel.statLine2Status="idle";if(!element){if(type=="extract"){mplayer.showAndAddExtractData("#EANF#");return;}else{if(type=="content"&&/^event:fail_if_found$/i.test(txt))return;mplayer.playingAgain=false;throw new RuntimeError("element "+tagName.toUpperCase()+" specified by "+cmd[4]+" was not found",921);}}};MacroPlayer.prototype.processElement=function(element,type,txt){if(im_Pref.getBoolPref("scroll")){var epos=ClickHandler.findElementPosition(element);this.currentWindow.scrollTo(epos.x-100,epos.y-100);}if(im_Pref.getBoolPref("highlight")){element.style.borderColor="#0000ff";element.style.borderWidth="2px";element.style.borderStyle="solid";}var tagName=element.tagName.toLowerCase();var doc=this.currentWindow.document;if(type=="extract"){TagHandler.onExtractParam(tagName,element,txt);}else if(type=="content"|| !type){if(txt&&/^event:(\S*)$/i.test(txt)){var etype=RegExp.$1.toLowerCase();switch(etype){case "saveitem":case "savepictureas":this.savePictureAs(element);break;case "savetargetas":case "savetarget":this.saveTargetAs(element);break;case "mouseover":var evt=doc.createEvent("MouseEvent");evt.initMouseEvent("mouseover",true,true,doc.defaultView,0,0,0,0,0,false,false,false,false,0,null);element.dispatchEvent(evt);break;case "fail_if_found":throw new RuntimeError("FAIL_IF_FOUND event",990);break;default:throw new BadParameter("unknown event type: "+etype);}}else{TagHandler.onContentParam(tagName,element,txt);}}};MacroPlayer.prototype.RegExpTable["url"]="^goto\\s*=\\s*("+im_strre+")\\s*$";MacroPlayer.prototype.ActionTable["url"]=function(cmd){var param=unwrapLine(mplayer.expandVariables(cmd[1])),scheme=null;if(!/^([a-z]+):.*/i.test(param)){param="http://"+param;}var ios=imns.Cc["@mozilla.org/network/io-service;1"].getService(imns.Ci.nsIIOService);try{ios.newChannel(param,null,null);}catch(e){Components.utils.reportError(e);throw new BadParameter("The URL syntax is not correct: '"+param+"'");}try{window.content.document.location=param;}catch(e){var s=e.toString();if(/NS_ERROR_FILE_NOT_FOUND/.test(s))throw new RuntimeError("File "+param+" not found",930);else throw e;}};MacroPlayer.prototype.RegExpTable["version"]="^(?:build\\s*=\\s*(\\S+))?"+"(?:\\s+recorder\\s*=\\s*(\\S+))?\\s*$";MacroPlayer.prototype.ActionTable["version"]=function(cmd){};MacroPlayer.prototype.RegExpTable["wait"]="^seconds\\s*=\\s*(\\S+)\\s*$";function WaitReporter(delay){this.period=100;this.counter=Math.round(delay/this.period);if(this.counter<=0)this.counter=1;this.timer=imns.Cc["@mozilla.org/timer;1"].createInstance(imns.Ci.nsITimer);this.timer.initWithCallback(this,this.period,imns.Ci.nsITimer.TYPE_REPEATING_PRECISE);mplayer.inWaitCommand=true;};WaitReporter.prototype={notify:function(timer){this.counter--;im_panel.statLine1="Waiting: "+(this.counter/1000*this.period).toFixed(2).toString();if(this.counter==0|| !mplayer.playing||mplayer.pauseIsPending){im_panel.statLine1="";this.timer.cancel();mplayer.inWaitCommand=false;setTimeout(function(){mplayer.playNextAction()},0);}}};MacroPlayer.prototype.ActionTable["wait"]=function(cmd){var param=Number(unwrapLine(mplayer.expandVariables(cmd[1])));if(isNaN(param))throw new BadParameter("SECONDS=<number>",1);param=Math.round(param*10)*100;if(param==0)param=10;else if(param<0)throw new BadParameter("positive number of seconds",1);new WaitReporter(param);};MacroPlayer.prototype.RegExpTable["winclick"]=".*";MacroPlayer.prototype.ActionTable["winclick"]=function(cmd){throw new UnsupportedCommand("WINCLICK");};MacroPlayer.prototype.RegExpTable["saveitem"]=".*";MacroPlayer.prototype.ActionTable["saveitem"]=function(cmd){};MacroPlayer.prototype.compileExpressions=function(){for(var x in this.RegExpTable){try{this.RegExpTable[x]=new RegExp(this.RegExpTable[x],"i");}catch(e){__loginf("failed on compiling regexp "+x);throw e;}}};MacroPlayer.prototype.__defineGetter__("currentWindow",function(){if(!this.m_wnd||this.m_wnd.closed|| !this.m_wnd.document)this.m_wnd=window.content;return this.m_wnd;});MacroPlayer.prototype.__defineSetter__("currentWindow",function(new_wnd){this.m_wnd=new_wnd;});MacroPlayer.prototype.observe=function(subject,topic,data){if(/^dl-(start|cancel|failed|done)$/.test(topic)){var action=RegExp.$1;var dwnld=subject.QueryInterface(imns.Ci.nsIDownload);switch(action){case "start":if(this.playing&&this.shouldWaitDownload){this.downloadArray.push(dwnld.id);this.waitingForDownload=true;var id=dwnld.id;this.downloadTimeout=setTimeout(function(){if(!mplayer.playing||mplayer.ignoreErrors)return;var dm=imns.Cc["@mozilla.org/download-manager;1"].getService(imns.Ci.nsIDownloadManager);try{var dl=dm.getDownload(id);if(dl.state==dm.DOWNLOAD_DOWNLOADING)dm.cancelDownload(id);}catch(e){Components.utils.reportError(e);return;}var msg="RuntimeError: download timeout";mplayer.errorCode= -802;mplayer.errorMessage=msg;mplayer.stop();im_panel.showErrorMessage(msg,802);},this.timeout*1000);}break;case "cancel":case "failed":case "done":if(this.playing&&this.shouldWaitDownload){var idx=this.downloadArray.indexOf[dwnld.id];if(idx!= -1){this.downloadArray.splice(idx,1);if(this.downloadTimeout){clearTimeout(this.downloadTimeout);this.downloadTimeout=null;}if(this.downloadChecksum){try{var check=this.calculateFileHash(dwnld.targetFile,this.downloadCheckAlg);if(check!=this.downloadChecksum){this.errorCode= -934;this.errorMessage="RuntimeError: "+"Checksum of downloaded file "+check+" doesn't match specified";im_panel.showErrorMessage(this.errorMessage,this.errorCode);if(!this.ignoreErrors)this.stop();this.downloadChecksum="";this.downloadCheckAlg="";}}catch(e){this.errorCode= -1;this.errorMessage=e.toString();im_panel.showErrorMessage(this.errorMessage,this.errorCode);if(!this.ignoreErrors)this.stop();}}}if(!this.downloadArray.length){this.waitingForDownload=false;setTimeout(function(){mplayer.playNextAction()},0);}}break;}}};MacroPlayer.prototype.topicsToObserve={"dl-done":false,"dl-cancel":false,"dl-failed":false,"dl-start":false,};MacroPlayer.prototype.registerObservers=function(){var os=imns.Cc["@mozilla.org/observer-service;1"].getService(imns.Ci.nsIObserverService);for(var x in this.topicsToObserve)os.addObserver(this,x,this.topicsToObserve[x]);};MacroPlayer.prototype.unregisterObservers=function(){var os=imns.Cc["@mozilla.org/observer-service;1"].getService(imns.Ci.nsIObserverService);for(var x in this.topicsToObserve)os.removeObserver(this,x,this.topicsToObserve[x]);};MacroPlayer.prototype.startLoadTimer=function(){if(this.loadTimer){this.loadTimer.stop();this.loadTimer=null;}this.loadTimer=new LCTimer();this.loadTimer.start();im_panel.statLine2Status="loading";};MacroPlayer.prototype.stopLoadTimer=function(){if(this.loadTimer){this.loadTimer.stop();im_panel.statLine2Status="idle";this.loadQueue=new Array();}};MacroPlayer.prototype.__defineGetter__("hasActiveLoads",function(){var wp=getBrowser().webProgress;return wp.isLoadingDocument;});MacroPlayer.prototype.onStateChange=function(progress,req,flag,stat){var url=null;if(!this.playing)return;const STATE_START=imns.Ci.nsIWebProgressListener.STATE_START;const STATE_STOP=imns.Ci.nsIWebProgressListener.STATE_STOP;const STATE_IS_NETWORK=imns.Ci.nsIWebProgressListener.STATE_IS_NETWORK;if(flag&STATE_START){try{if(req){if(!this.waitingForPageLoad){this.waitingForPageLoad=true;this.startLoadTimer();this.networkError=false;this.requestURL=req.QueryInterface(imns.Ci.nsIChannel).originalURI.spec;}}}catch(e){Components.utils.reportError(e);}}else if(flag&STATE_STOP){try{if(this.waitingForPageLoad&& !this.hasActiveLoads){this.networkError= !(Components.isSuccessCode(stat)||stat==0x80540008||stat==0x805D0021);this.waitingForPageLoad=false;this.stopLoadTimer();setTimeout(function(){mplayer.playNextAction()},0);}}catch(e){Components.utils.reportError(e);}}};MacroPlayer.prototype.onLocationChange=function(progress,request,uri){};MacroPlayer.prototype.onProgressChange=function(progress,request,cur_self_progress,max_self_progress,cur_total_progress,max_total_progress){};MacroPlayer.prototype.onStatusChange=function(progress,request,status,message){};MacroPlayer.prototype.onSecurityChange=function(web_progress,request,state){};MacroPlayer.prototype.QueryInterface=function(iid){if(iid.equals(imns.Ci.nsIWebProgressListener)||iid.equals(imns.Ci.nsISupportsWeakReference)||iid.equals(imns.Ci.nsISupports))return this;throw Components.results.NS_NOINTERFACE;};MacroPlayer.prototype.parseMacro=function(warnOnLoop){const comment=new RegExp("^\\s*(?:'.*)?$");this.source=this.source.replace(/\r+/g,"");var lines=this.source.split("\n");for(var i=0;i<lines.length;i++){if(lines[i].match(comment)){continue;}if(warnOnLoop&&/{{!loop}}/i.test(lines[i])&& !im_Pref.getBoolPref('noloopwarning')){warnOnLoop=false;window.openDialog('chrome://imacros/content/loopwarning.xul','','modal,centerscreen');}if(/^\s*(\w+)(?:\s+(.*))?$/.test(lines[i])){var command=RegExp.$1.toLowerCase();var arguments=RegExp.$2?RegExp.$2:"";if(!(command in this.RegExpTable))throw new SyntaxError("unknown command: "+command.toUpperCase()+", line: "+(i+1));var args=this.RegExpTable[command].exec(arguments);if(!args)throw new SyntaxError("wrong format of "+command.toUpperCase()+" command"+", line: "+(i+1));this.actions.push({name:command,args:args,line:i+1});}else{throw new SyntaxError("can not parse macro line: "+lines[i]);}}};MacroPlayer.prototype.play=function(file,times){const comment=new RegExp("^\\s*(?:'.*)?$");try{this.reset();this.registerObservers();var browser=getBrowser();const NOTIFY_STATE_DOCUMENT=imns.Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT;browser.addProgressListener(this,NOTIFY_STATE_DOCUMENT);if(!file.exists())throw new RuntimeError("Macro "+file.leafName+" not found",930);this.source=im_FIO.readTextFile(file);if(!this.source.length)throw new RuntimeError("File "+file.path+" is empty or can not be read",931);this.currentMacro=file.leafName;var line_re=/\r?\n/g,count=0;while(line_re.exec(this.source))count++;if(count>im_Pref.getIntPref("maxMacroLength")){var msg="Macro length exceeds "+im_Pref.getIntPref("maxMacroLength")+" lines, this might take too long to load.\n\n"+"Would you like to proceed?\n\n"+"Note: You can disable this warning message by increasing the"+"\n\"extensions.imacros.maxMacroLength\" parameter.";if(!im_Dialogs.confirm(msg)){this.stop();return;}}if(!times||times<0)times=1;else if(times>1)this.cycledReplay=true;var warnOnLoop= !(this.cycledReplay||in_iimPlay||calledmacro);this.parseMacro(warnOnLoop);im_panel.showLines(this.source);this.globalTimer.start();imacrosr();this.player=this.getPlayer(times);this.playing=true;setTimeout(function(){mplayer.playNextAction()},0);}catch(e){Components.utils.reportError(e);this.errorCode=e.errnum? -1*Math.abs(e.errnum): -1001;this.errorMessage=(e.name?e.name:"Error")+": "+e.message;im_panel.showErrorMessage(this.errorMessage,this.errorCode);this.stop();}};MacroPlayer.prototype.playNextAction=function(){if(this.pauseIsPending){this.pauseIsPending=false;this.paused=true;return;}else if(this.paused||this.waitingForDelay||this.waitingForDownload||this.waitingForPageLoad||this.inWaitCommand){return;}else if(this.networkError){this.networkError=false;if(!this.ignoreErrors){this.errorCode= -933;this.errorMessage="RuntimeError: "+"unable to load "+this.requestURL;im_panel.showErrorMessage(this.errorMessage,this.errorCode);this.stop();}else{setTimeout(function(){mplayer.playNextAction()},this.delay);}}else{if(!this.player)return;if(!this.player.next())this.stop();}};MacroPlayer.prototype.stop=function(){this.playing=false;if(this.player){this.player.close();this.player=null;this.unregisterObservers();var browser=getBrowser();browser.removeProgressListener(this);this.stopLoadTimer();}this.saveStopwatchResults();this.vars=new Array(3);this.userVars=new Object();im_panel.currentLoopValue=1;imacrosi();imacross();if(in_iimPlay&&iim_nested){var nloop=getNestedLoop();iim_nested=false;nloop.exit("iim-play");}else{im_panel.showMacroTree();if(calledmacro){if(connector){connector.CompleteCommand(cookie,this.errorCode,im_msg2con(this.errorCode,this.errorMessage,this.getExtractData(),this.lastPerformance));}calledmacro=false;}}};MacroPlayer.prototype.saveStopwatchResults=function(){this.globalTimer.stop();this.totalRuntime=this.globalTimer.getElapsedTime();var format=function(x){var m=x.toFixed(3).match(/^(\d+)\.(\d{3})/);var s=m[1];while(s.length<5)s="0"+s;return s+"."+m[2];};this.lastPerformance="Total Runtime="+format(this.totalRuntime)+"[!S!]";if(this.stopwatchResults.length){var file;if(this.stopwatchFile){file=this.stopwatchFile;}else{if(this.stopwatchFolder)file=this.stopwatchFolder;else file=im_Pref.getFilePref("defdownpath");var filename=/^(.+)\.iim$/.test(this.currentMacro)?RegExp.$1:this.currentMacro;file.append("performance_"+filename+".csv");}var now=new Date();var d=formatDateString("yyyy/dd/mm",now);var t=formatDateString("hh:nn",now);var newline=__is_windows()?"\r\n":"\n";var s="\"Date: "+d+"  Time: "+t+", Macro: "+this.currentMacro+", Status: "+this.errorMessage+" ("+this.errorCode+")\",";s+=newline;for(var i=0;i<this.stopwatchResults.length;i++){var r=this.stopwatchResults[i];s+=r.id+","+r.elapsedTime.toFixed(3).toString();s+=newline;this.lastPerformance+=r.id+"="+format(r.elapsedTime)+"[!S!]";}try{im_FIO.appendTextFile(file,s);}catch(e){this.errorCode= -931;this.errorMessage="RuntimeError: "+"Can not write to file "+file.path;im_panel.showErrorMessage(this.errorMessage,this.errorCode);}}};MacroPlayer.prototype.pause=function(){this.pauseIsPending=true;};MacroPlayer.prototype.unPause=function(){this.paused=false;setTimeout(function(){mplayer.playNextAction()},0);};MacroPlayer.prototype.exec=function(action){this.ActionTable[action.name](action.args);;this.playingAgain=false;this.waitingForDelay=true;setTimeout(function(){mplayer.waitingForDelay=false;mplayer.playNextAction();},this.delay);if(this.singleStepMode)pause();return true;};MacroPlayer.prototype.getPlayer=function(times){while(this.currentLoop++ <times){im_panel.currentLoopValue=this.currentLoop;var actions=this.actions.slice(0);actions.reverse();while(actions.length){var action=actions.pop();im_panel.highlightLine(action.line);try{yield(this.exec(action));}catch(e if e instanceof ShouldWaitSignal){if(e.playAgain){actions.push(action);this.playingAgain=true;}if(e.delay){setTimeout(function(){mplayer.waitingForDelay=false;mplayer.playNextAction();},e.delay);}yield true;}catch(e if e instanceof RuntimeError){Components.utils.reportError(e);if(!this.ignoreErrors){this.errorCode=e.errnum? -1*Math.abs(e.errnum): -1001;this.errorMessage=e.toString()+", line: "+(action.line+mplayer.linenumber_delta);im_panel.showErrorMessage(this.errorMessage,this.errorCode);yield false;}}catch(e){Components.utils.reportError(e);if(!this.ignoreErrors){this.errorCode=e.errnum? -1*Math.abs(e.errnum): -1001;this.errorMessage=(e.name?e.name:"Error")+": "+e.message+", line: "+(action.line+mplayer.linenumber_delta);im_panel.showErrorMessage(this.errorMessage,this.errorCode);yield false;}}}this.firstLoop=false;}yield false;};MacroPlayer.prototype.reset=function(){this.m_wnd=null;this.watchTable=new Object();this.stopwatchResults=new Array();this.totalRuntime=0;this.stopwatchFile=null;this.stopwatchFolder=null;this.lastWatchValue=0;this.lastPerformance="";this.shouldStopOnError=false;this.actions=new Array();this.source="";this.ignoreErrors=false;this.playing=false;this.paused=false;this.pauseIsPending=false;this.currentLoop=0;this.firstLoop=true;this.playingAgain=false;this.downloadArray=new Array();this.waitingForDownload=false;this.waitingForPageLoad=false;this.networkError=false;this.inWaitCommand=false;this.downloadFilename=null;this.downloadFolder=null;this.downloadCheckAlg="";this.downloadChecksum="";this.loadTimer=null;this.globalTimer.init();this.loadQueue=new Array();this.extractData="";this.shouldPopupExtract=true;this.dataSource=new Array();this.dataSourceColumns=0;this.dataSourceLine=0;this.dataSourceFile="";this.timeout=im_Pref.getIntPref("maxwait");this.tagTimeout=0;this.delay=im_Pref.getIntPref("delay");this.shouldFilterImages=true;this.shouldDownloadPDF=true;this.startTabIndex=getBrowser().mTabContainer.selectedIndex;this.errorCode=1;this.errorMessage="OK";this.singleStepMode=false;this.waitingNextStep=false;this.cycledReplay=false;this.linenumber_delta=0;im_panel.mboxResetError();this.clickmode="dom";};MacroPlayer.prototype.setUserVar=function(name,value){this.userVars[name.toLowerCase()]=value;};MacroPlayer.prototype.getUserVar=function(name){return this.userVars[name.toLowerCase()];};MacroPlayer.prototype.hasUserVar=function(name){return this.userVars.hasOwnProperty(name.toLowerCase());};MacroPlayer.prototype.getExtractData=function(){return this.extractData;};MacroPlayer.prototype.addExtractData=function(str){if(this.extractData.length){this.extractData+="[EXTRACT]"+str;}else{this.extractData=str;}};MacroPlayer.prototype.clearExtractData=function(){this.extractData="";};MacroPlayer.prototype.showAndAddExtractData=function(str){this.addExtractData(str);if(!this.shouldPopupExtract||calledmacro||in_iimPlay)return;var param={extractData:str};window.openDialog('chrome://imacros/content/extract.xul','','modal,centerscreen',param);};MacroPlayer.prototype.loadDataSource=function(filename){var file;if(filename.indexOf(__psep())== -1){file=im_Pref.getFilePref("defdatapath");file.append(filename);}else{file=im_FIO.openNode(filename);}if(!file.exists())throw new RuntimeError("Data source file does not exist",930);this.dataSourceFile=file.path;var data=im_FIO.readTextFile(file);if(!/\r?\n$/.test(data))data+="\n";this.dataSource=new Array();const field='\\s*("(?:[^\"]+|"")+"|[^,\n\r]*)\\s*(,|\r?\n|\r)';var re=new RegExp(field,"g"),m,vals=new Array();while(m=re.exec(data)){var value=m[1],t;if(t=value.match(/^\"((?:\n|.)*)\"$/))value=t[1];value=value.replace(/\"{2}/g,'"');vals.push(value);if(m[2]!=","){this.dataSource.push(vals.slice(0));vals=new Array();}}if(!this.dataSource.length)throw new RuntimeError("can not parse datasource file "+filename,952);};MacroPlayer.prototype.getColumnData=function(col){var line=this.dataSourceLine||this.currentLoop;if(!line)line=1;if(col>this.dataSourceColumns)throw new RuntimeError("Column number "+col+" greater than total number"+" of columns "+this.dataSourceColumns,953);return this.dataSource[line-1][col-1];};MacroPlayer.prototype.expandVariables=function(param){param=param.replace(/#novar#\{\{/ig,"#NOVAR#{");var handleVariable=function(match_str,var_name){var t=null;if(t=var_name.match(/^!var([123])$/i)){return mplayer.vars[__int(t[1])];}else if(t=var_name.match(/^!extract$/i)){return mplayer.getExtractData();}else if(t=var_name.match(/^!loop$/i)){return mplayer.currentLoop;}else if(t=var_name.match(/^!urlcurrent$/i)){return content.document.location;}else if(t=var_name.match(/^!now:(\S+)$/i)){return formatDateString(t[1]);}else if(t=var_name.match(/^!col(\d+)$/i)){return mplayer.getColumnData(__int(t[1]));}else if(t=var_name.match(/^!datasource_line$/i)){return mplayer.dataSourceLine||mplayer.currentLoop;}else if(t=var_name.match(/^!datasource_columns$/i)){return mplayer.dataSourceColumns;}else if(t=var_name.match(/^!datasource$/i)){return mplayer.dataSourceFile;}else if(t=var_name.match(/^!stopwatchtime$/i)){var value=mplayer.lastWatchValue.toFixed(3).toString();return value;}else if(t=var_name.match(/^!clipboard$/i)){return im_Clipboard.getString()||"";}else if(t=var_name.match(/^!timeout$/i)){return mplayer.timeout;}else if(t=var_name.match(/^!singlestep$/i)){return mplayer.singleStepMode.toString();}else{var value="__undefined__";if(mplayer.hasUserVar(var_name))value=mplayer.getUserVar(var_name);return value;}};param=param.replace(/\{\{(\S+?)\}\}/g,handleVariable);param=param.replace(/#novar#\{(?=[^{])/ig,"{{");return param;};var mplayer=new MacroPlayer();